package com.javasm.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * @Author：MoDebing
 * @Version：1.0
 * @Date：2022-09-04-19:54
 * @Description: 登录逻辑
 */
@Service
public class UserServiceImpl implements UserDetailsService {

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {

        String passwordEncode = passwordEncoder.encode("123456");

        return new User("modebing",passwordEncode, AuthorityUtils.commaSeparatedStringToAuthorityList("admin"));
    }
}
